//
//  ZZCircle.m
//  ZZCirCle
//
//  Created by stonesMonkey on 2017/9/15.
//  Copyright © 2017年 evan. All rights reserved.
//

#import "ZZCircle.h"

@interface ZZCircle()

@property (nonatomic, assign)CGFloat neiLayerWidth;

@end

@implementation ZZCircle


- (instancetype)initWithFrame:(CGRect)frame {
    
    if (self = [super initWithFrame:frame]) {
        
        self.neiLayerWidth = 68;
        [self setupLayer:frame];
    }
    return self;
}

- (void)setupLayer:(CGRect)rect {
    
     int radius = rect.size.width/2;
    
    CAGradientLayer *gradientLayer = [CAGradientLayer layer];
    gradientLayer.frame = CGRectMake(0, 0, rect.size.width, rect.size.height);
    gradientLayer.colors = @[(__bridge id)[UIColor colorWithRed:167/255.0 green:39/255.0 blue:108 / 255.0 alpha:0.8].CGColor,(__bridge id)[UIColor yellowColor].CGColor];
    gradientLayer.startPoint = CGPointMake(0,0);
    gradientLayer.endPoint = CGPointMake(0,1);
    
    [self.layer addSublayer:gradientLayer];
    self.layer.cornerRadius = radius;
    self.layer.masksToBounds = YES;
    
    CALayer *layer = [CALayer layer];
    layer.bounds= CGRectMake(0, 0, self.neiLayerWidth, self.neiLayerWidth);
    layer.position=CGPointMake(rect.size.width / 2, rect.size.height / 2);
    layer.backgroundColor = [UIColor whiteColor].CGColor;
    layer.cornerRadius = self.neiLayerWidth / 2;
    [self.layer addSublayer:layer];
    
}


@end
